package ${cfg.package_name}.dto;


import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import java.util.List;
import java.util.Date;
import com.rt.easyjava.common.base.BaseV3Dto;

/**
 * ${table.comment!}
 * @author ${author}
 * @since ${date}
 */

@ApiModel(description = "${entity}Dto传输对象")
@Data
@ToString
@EqualsAndHashCode(callSuper = false)
@AllArgsConstructor
@NoArgsConstructor<#--@Builder-->
public class ${entity}Dto extends BaseV3Dto{
    private static final long serialVersionUID = 1L;

<#assign ignColumnList=["id","deleteFlag","createTime","updateTime","creator","creatorId","updator","updatorId","companyId","version"]/>

<#list cfg.columnList as column>
<#if (column.tableAliasName == "" || column.tableAliasName == "t1") && !ignColumnList?seq_contains(column.propertyName) >
    <#if column.columnType4JavaEncap=='Date' || column.columnType4JavaEncap=='Timestamp'>
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date ${column.propertyName};
    <#elseif column.propertyName=='id'>
    private ${column.columnType4JavaEncap} ${column.propertyName}; // id或Id结尾，数据类型保持数据库一致
    <#elseif column.dataResource==1 || ((column.columnType?exists) && (column.columnType=='select-multi' || column.columnType=='select'))>
    @ApiModelProperty(hidden = true)
    private Object ${column.propertyName}; // 枚举，通过dozer转换:  当bean->dto时, 放入json对象 如{'id':1, 'name':'无效'}； 当dto->bean时, object->Integer
    <#else>
    private ${column.columnType4JavaEncap} ${column.propertyName}; // ${column.comment!}
    </#if>
</#if>
</#list>

<#if cfg.hasM2O>
    // Many to One
    // 关联对象： dozer 自动进行深度映射
    <#--private ${cfg.classNameFirstWordUpperM2O}BizDto ${cfg.classNameFirstWordLowerM2O};-->
    <#list cfg.tableNameM2OList as tableNameMap>
    @ApiModelProperty(hidden = true)
    private ${tableNameMap.className}BizDto ${tableNameMap.classInstance};
    </#list>
</#if>
<#list cfg.o2mList as o2m>
<#if o2m.hasO2M>
    // One to Many
    // 关联对象： dozer 自动进行深度映射
    @ApiModelProperty(hidden = true)
    private List<${o2m.classNameFirstWordUpperO2M}BizDto> ${o2m.classNameFirstWordLowerO2M}List;
</#if>
</#list>
<#if cfg.isTreeTable == true>
    // 当树表时，用这个存储子树
    @ApiModelProperty(hidden = true)
    private List<${entity}BizDto> ${table.entityPath}List;
</#if>

    //----------------------------------------
    // 与页面交互时的参数
    //----------------------------------------
<#list cfg.columnList as column>
    <#if (column.columnType4JavaEncap=='Date' || column.columnType4JavaEncap=='Timestamp' || column.queryType=='between') && !ignColumnList?seq_contains(column.propertyName)>
    private String ${column.propertyName}_Start;
    private String ${column.propertyName}_End;
    </#if>
</#list>


    // 自动装载数据：调用装载方法assemble(), 一定要用第一个私有变量，以确保方法里对各属性引用有效
    public Long getId() {
        assembleAuto();
        return super.getId();
    }

    // 自动装载数据
    public void assembleAuto() {
        try {
            // System.out.println("assembleAuto");
        }catch (Exception e){
            e.printStackTrace();
        }
    }

}
